const jwt=require('jwt-simple')
//token加解密使用到的密钥字符串
const secret='kjbdfksfnl;jsijf98ikldsnf(U*(Y78l156156sdns?>?>p[lsadiidfko'

//生成token
const getToken=(payload={})=>{
    //设置token失效时间
    payload.exp=Math.floor(Date.now()/1000)+5*60
    return jwt.encode(payload,secret)
}

//验证token
const verifyToken=token=>{
    return jwt.decode(token,secret)
}

module.exports={
    getToken,
    verifyToken
}